﻿using DevExpress.XtraBars;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MDIDemo.PublicSetUp
{
    /// <summary>
    /// 设置工具栏Bar
    /// </summary>
    public class Class_SetUpBar
    {
        /// <summary>
        /// 设置Bar
        /// </summary>
        /// <param name="Bar"></param>
        /// <param name="BarText"></param>
        public void setBar(Bar Bar, string BarText)
        {
            Bar.OptionsBar.AllowQuickCustomization = false;
            Bar.Text = BarText;

        }

        private ItemPro[] arrayself;
        private struct ItemPro
        {
            public string ItemContent;
            public string ItemCaption;
        }
        private void pri_IniClass()
        {
        }
        public bool pub_SetBar(Bar p_BarName, bool p_bool_IsOnlySet)
        {
            p_BarName.OptionsBar.AllowQuickCustomization = false;
            p_BarName.OptionsBar.DrawDragBorder = false;//是否支持拖动
            p_BarName.OptionsBar.MultiLine = false;
            p_BarName.Manager.AllowCustomization = false;
            p_BarName.OptionsBar.DrawSizeGrip = false;
            p_BarName.OptionsBar.UseWholeRow = false;

            //p_BarName.Appearance.Font = new Font("ËÎÌå", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
    //        p_BarName.Appearance.Options.UseFont = true;
//            p_BarName.BarItemHorzIndent = 8;
  //          p_BarName.BarItemVertIndent = 4;

            if (!p_bool_IsOnlySet)
            {
                for (int i = 0; i < p_BarName.LinksPersistInfo.Count; i++)
                {
                    string str_TypeName = p_BarName.LinksPersistInfo[i].Item.GetType().Name;
                    if (str_TypeName.ToLower() == "barbuttonitem")
                    {
                        BarButtonItem BarItem = (BarButtonItem)p_BarName.LinksPersistInfo[i].Item;

                        if (BarItem.Visibility != BarItemVisibility.OnlyInCustomizing)
                        {
                            BarItem.Tag = true;
                            BarItem.PaintStyle = BarItemPaintStyle.CaptionGlyph;
                            BarItem.ItemAppearance.Disabled.Font = new System.Drawing.Font("Tahoma", 7.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                            BarItem.ItemAppearance.Disabled.Options.UseFont = true;
                        }
                    }
                    if (str_TypeName.ToLower() == "barsubitem")
                    {
                        BarSubItem BarItem = (BarSubItem)p_BarName.LinksPersistInfo[i].Item;
                        if (BarItem.Visibility != BarItemVisibility.OnlyInCustomizing)//ÐèÒªÏÔÊ¾µÄ°´Å¥²Å½øÐÐÉèÖÃ
                        {
                            BarItem.Tag = true;//ÔÙºóÔö¼Ó-----------------------
                            BarItem.PaintStyle = BarItemPaintStyle.CaptionGlyph;
                        }
                    }
                }
            }

            return true;
        }
        public bool pub_SetMenuBar(Bar p_BarName, bool p_bool_IsOnlySet)
        {
            p_BarName.Appearance.Font = new Font("ËÎÌå", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            p_BarName.Appearance.Options.UseFont = true;
            p_BarName.BarItemHorzIndent = 8;
            p_BarName.BarItemVertIndent = 4;
            p_BarName.OptionsBar.AllowQuickCustomization = false;
            //p_BarName.OptionsBar.DrawDragBorder = false;
            p_BarName.OptionsBar.MultiLine = true;
            p_BarName.Manager.AllowCustomization = false;
            p_BarName.OptionsBar.DrawSizeGrip = true;
            return true;
        }
        /// <summary>
        /// ÉèÖÃToolBarµÄÊôÐÔÓë°´Å¥µÄTagÈ¨ÏÞ
        /// </summary>
        /// <param name="p_BarName">Bar¶ÔÏó</param>
        /// <param name="p_bool_IsOnlySet">ÊÇ·ñÖ»ÊÇÉèÖÃÊôÐÔ</param>
        /// <returns></returns>
        public void pub_SetToolBar(Bar p_BarName, bool p_bool_IsOnlySet)
        {
            p_BarName.OptionsBar.AllowQuickCustomization = false;
            p_BarName.OptionsBar.DrawDragBorder = false;//是否支持拖动
            p_BarName.OptionsBar.MultiLine = false;
            p_BarName.Manager.AllowCustomization = false;
            p_BarName.OptionsBar.DrawSizeGrip = false;
            p_BarName.OptionsBar.UseWholeRow = false;
        }
        public void pub_SetBar(Bar p_BarName)
        {
            pub_SetBar(p_BarName, false);
        }

    }
}
